********************************************************************************
*** This program holds the collection of do-files needed to generated the 
*** data used in the project:
***  
*** Do Lower Minimum Wages for Young Workers Raise their Employment:
***				Evidence from a Danish Discontinuity
***
***		    Claus Thustrup Kreiner, Daniel Reck & Peer Ebbesen Skov
***
*** First created: 08/08 - 2015 by Peer E. Skov (ps@aut.ac.nz)
*** Last updated:  07/02 - 2019 by Peer E. Skov (ps@aut.ac.nz)
*******************************************************************************;
clear
clear matrix
set emptycells drop 
set matsize 10000

** Setting up a few globals to refer to data folders
global minwage E:\Data\workdata\703788\minwage\stata // project folder
global dst E:\Data\rawdata\703788 // DST data
global data E:\Data\workdata\703788\minwage\data // data folder
global out E:\Data\workdata\703788\minwage\out // results folder

* Data 1: Selecting cohorts 1992-1999 and keeping individuals who are in DK
*		  in one year from 2008-2015. 
* out: "$data\minwage_data01_pnr_key_cohort1992_1999.dta"	  
do $minwage\data01.do

* Data 2: Match cohorts 1992-1999 to full payroll data.
*		Update payroll records with filed corrections
* out: ("$data\minwage_data02_`t'_29012019.dta", t = 2012/2015)
do $minwage\data02.do

* Data 3: Set up a panel so all indv. have 48 empty earnings
* 		  records. 
* out: ("$data\minwage_data3_2012_2015.dta")
do $minwage\data03.do

* Data 4: onthly wage, monthly hours are trimmed at p1 and p99.
*		  where p1 and p99 refer to percentiles by event-time and month.
* out: "$data\minwage_data4_2012_2015.dta",
do $minwage\data04.do

* Data 5: Merging apprentices information onto data: Note: main esitmation data set:
* Out:  minwage_data5_estimation_data_2012_2015.dta
do $minwage\data05.do

* Data 6: Constructing the dataset with standardized GPA results and education enrollment status.
* Out:  $data\minwage_data6_stdgpa.dta & $data\minwage_data6_ongoing_edu.dta
do $minwage\data06.do

* Data 7: Constructing the dataset with parental income. 
* Out:  "$data\parental_income_ptiles10.dta"
do $minwage\data07.do

* Data 8: (SA) Selecting the relevant variables and keeping ALL social assistance benefint recipients from e-Income.	
*		   Mergeing indv. on to the relevant cohorts and keeping matches.
* Out:  "$data\minwage_data08_SA_`t'_04022019.dta" t = 2013 /2015
do $minwage\data08.do

* Data 9: (SA) Collecting the final dataset: dummy variable to indicate SA recipient
* Out:  "$data\minwage_data09_SA_2012_2015.dta"
do $minwage\data09.do

* Data 10: Full payroll data for 2013.
* Out:  "$data\minwage_data10_payroll_all_2013.dta" 
do $minwage\data10.do

********************************************************************************
*************************** MAIN ESTIMATION DATA SET ***************************
***************** minwage_data5_estimation_data_2012_2015.dta ******************
********************************************************************************
* Descrp 1: 
* Out: Figure A.1 
do $minwage\descrp01.do

* Descrp 2: 
* Out: Figure A.2.
do $minwage\descrp02.do

* Descrp 3: 
* Out: Table 1-Panel B & Table A.2
do $minwage\descrp03.do

* Descrp 4: 
* Out:  Figure A.6
do $minwage\descrp04.do

* Descrp 5: 
* Out:  Figure A.8
do $minwage\descrp05.do

*********************************** ANALYSIS ***********************************

* Analysis 1: 
* Out: Figure 1 and Figure 2.
do $minwage\analys01.do

* Analysis 2:
* Out: Figure A.3
do $minwage\analys02.do

* Analysis 3:
* Out: Figure A.4
do $minwage\analys03.do

* Analysis 4:
* Out: Table 3.
do $minwage\analys04.do

* Analysis 5: 
* Out: Figure 4
do $minwage\analys05.do

* Analysis 6:  
* Out: Figure 6
do $minwage\analys06.do

* Analysis 7:  
* Out: Figure 3
do $minwage\analys07.do

* Analysis 8:  
* Out: Figure 3
do $minwage\analys08.do

* Analysis 9:  
* Out: Figure A.5
do $minwage\analys09.do
***************************** REGRESSIONS **************************************

* Reg 1 :  
* Out: Table 2
do $minwage\reg01.do

* Reg 2: 
* Out: Table A.4:
do $minwage\reg02.do

* Reg 3:  
* Out: Figure 5 and Figure A.9
do $minwage\reg03.do

* Reg 4:  
* Out: Figure 5 and Figure A.9
do $minwage\reg04.do

* Reg 5:  
* Out: Figure A.7:
do $minwage\reg05.do

* Reg 6: 
* Out: Table 2
do $minwage\reg06.do
